/*************************************************************************
	> File Name: P1211.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-03-18 09:34:57
 ************************************************************************/
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int digit(int n) {
    if (n == 0) return 1;
    return floor(log10(n)) + 1;
}

int is_val(int n, bool check[]) {
    while (n) {
        if (check[n % 10] == 0) return 0;
        n /= 10;
    }
    return 1;
}

int solve(int arr[], int n, bool check[]) {
    int cnt = 0;
    sort(arr, arr + n);
    int l = arr[0], r = arr[n - 1];
    for (int a = l * 111; a <= r * 111; a++) {
        if (!is_val(a, check)) continue;
        for (int b = l * 11; b <= r * 11; b++) {
            if (!is_val(b, check)) continue;
            int ge = b % 10, shi = b / 10;
            if (digit(a * ge) != 3) continue;
            if (digit(a * shi) != 3) continue;
            if (!is_val(a * ge, check)) continue;
            if (!is_val(a * shi, check)) continue;
            if (digit(a * b) != 4) continue;
            if (!is_val(a * b, check)) continue;
            cnt += 1;
        }
    }
    return cnt;
}

int main() {
    int n, arr[10] = {0};
    bool check[10];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        check[arr[i]] = true;
    }
    cout << solve(arr, n, check) << endl;
    return 0;
}
